package com.ncloud.timetask.dashboard.impl;

import com.ncloud.timetask.dashboard.mapper.MoveHistoryMapper;
import com.ncloud.timetask.dashboard.service.MoveHistoryServer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * Created by shiqiang on 2017/7/6.
 */
@Service
public class MoveHistoryServerImpl implements MoveHistoryServer{
    private final static Logger logger = LoggerFactory.getLogger(MoveHistoryServerImpl.class);
    @Autowired
    private MoveHistoryMapper moveHistoryMapper;
    @Transactional
    @Override
    public void moveOrderHis(Long orderId) {
        moveHistoryMapper.insertHisOrder(orderId);
        moveHistoryMapper.deleteByOrderId(orderId);
    }
    @Transactional
    @Override
    public void moveWorkHis(Long orderId) {
        moveHistoryMapper.insertHisWork(orderId);
        moveHistoryMapper.deleteHisWork(orderId);
    }

    @Override
    public Integer orderIsMove(String state, Long orderId) {
        return moveHistoryMapper.getNotIsCurrentState(state,orderId);
    }

    @Override
    public int updateWorkStateHis(Long orderId) {
        return moveHistoryMapper.updateWorkStateHis(orderId);
    }
}
